define([
    "models/menu",
    // "libs/webix/sidebar/sidebar"
], function (Menu) {

    function onReady() {
        // var menuToHide = [];
        // this.data.eachLeaf(0, function (each) {
        //     if (!sessionStorage.getItem("ROLE_" + each.id.toUpperCase()+"_QUERY")) menuToHide.push(each.id)
        // });
        // for (var i = 0; i < menuToHide.length; i++) {
        //     this.remove(menuToHide[i])
        // }
        // menuToHide = [];
        // this.data.eachChild(0, function (eachChild) {
        //     if (!this.getFirstChildId(eachChild.id)) menuToHide.push(eachChild.id)
        // }.bind(this));
        // for (var j = 0; j < menuToHide.length; j++) {
        //     this.remove(menuToHide[j])
        // }
    }

    return {
        $ui: {
            view: "sidebar",
            id: 'menu_ui',
            width: 200,
            data: Menu.data,
            ready: onReady,
            on: {
                onAfterSelect: function (id) {
                    this.$scope.show("./" + id);
                }
            }
        }
    };

});
